package com.qgs.waf.controller.zbks;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qgs.waf.service.ZbksDeviceService;

/**
 * 值班看守
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value = "/zbks/dgc")
public class ZbksGuardDutyController {
	private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
	@Autowired
	private ZbksDeviceService zs;

	@ResponseBody
	@RequestMapping(value = { "attackPreview" }, produces = "application/json; charset=utf-8")
	public String attackPreview(@RequestParam(value = "pn", required = false, defaultValue = "1") int pn, @RequestParam(value = "ps", required = false, defaultValue = "20") int ps, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date end, @RequestParam(value = "province", required = false) String province, @RequestParam(value = "industry", required = false) String industry) {
		return zs.attackPreview(pn, ps, SDF.format(start), SDF.format(end), province, industry);
	}

	/**
	 * 攻击原始数据
	 * 
	 * @param pn
	 *            int 页数
	 * @param ps
	 *            int 每页条数
	 * @param table
	 *            表名称
	 * @param begin
	 *            String 开始时间
	 * @param end
	 *            String 结束时间
	 * @param province
	 *            String 省份
	 * @param industry
	 *            String 行业
	 * @param wafid
	 *            String wafid
	 * @return PageInfo 分页后的数据
	 */
	@ResponseBody
	@RequestMapping(value = "attackOriginalData/{table}", produces = "application/json; charset=utf-8")
	public String attackOriginalData(@RequestParam(value = "pn", required = false, defaultValue = "1") int pn, @RequestParam(value = "ps", required = false, defaultValue = "20") int ps, @PathVariable(value = "table") String table, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date end, @RequestParam(value = "province", required = false) String province, @RequestParam(value = "industry", required = false) String industry,@RequestParam(value = "wafid", required = false) String wafid) {
		return zs.attackOriginalData(pn, ps, table, SDF.format(start), SDF.format(end), province, industry,wafid);
	}

}
